package com.employ.job.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.employ.common.annotation.Log;
import com.employ.common.core.controller.BaseController;
import com.employ.common.core.domain.AjaxResult;
import com.employ.common.enums.BusinessType;
import com.employ.job.domain.EmpJobs;
import com.employ.job.service.IEmpJobsService;
import com.employ.common.utils.poi.ExcelUtil;
import com.employ.common.core.page.TableDataInfo;

/**
 * 职位Controller
 *
 * @author ruoyi
 * @date 2025-02-24
 */
@RestController
@RequestMapping("/job/jobs")
public class EmpJobsController extends BaseController
{
    @Autowired
    private IEmpJobsService empJobsService;

    /**
     * 查询职位列表
     */
    @PreAuthorize("@ss.hasPermi('job:jobs:list')")
    @GetMapping("/list")
    public TableDataInfo list(EmpJobs empJobs)
    {
        startPage();
        List<EmpJobs> list = empJobsService.selectEmpJobsList(empJobs);
        return getDataTable(list);
    }

    /**
     * 导出职位列表
     */
    @PreAuthorize("@ss.hasPermi('job:jobs:export')")
    @Log(title = "职位", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmpJobs empJobs)
    {
        List<EmpJobs> list = empJobsService.selectEmpJobsList(empJobs);
        ExcelUtil<EmpJobs> util = new ExcelUtil<EmpJobs>(EmpJobs.class);
        util.exportExcel(response, list, "职位数据");
    }

    /**
     * 获取职位详细信息
     */
    @PreAuthorize("@ss.hasPermi('job:jobs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(empJobsService.selectEmpJobsById(id));
    }

    /**
     * 新增职位
     */
    @PreAuthorize("@ss.hasPermi('job:jobs:add')")
    @Log(title = "职位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmpJobs empJobs)
    {

        return toAjax(empJobsService.insertEmpJobs(empJobs));
    }

    /**
     * 修改职位
     */
    @PreAuthorize("@ss.hasPermi('job:jobs:edit')")
    @Log(title = "职位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmpJobs empJobs)
    {
        return toAjax(empJobsService.updateEmpJobs(empJobs));
    }

    /**
     * 删除职位
     */
    @PreAuthorize("@ss.hasPermi('job:jobs:remove')")
    @Log(title = "职位", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(empJobsService.deleteEmpJobsByIds(ids));
    }
}
